Vue.component("zz-side-bar", {
    template: `<div class="zz-sider">
        <img 
            v-if="hasBg"
            src="./images/sideBar/sider-bg.png" alt="" class="zz-sider-bg">
        <div class="ds-navList-wrap">
            <div class="ds-navList-template"></div>
        </div>
    </div>`,
    props: {
        // 菜单数据
        menuData:{
            type:Array,
            default(){
                return [];
            }
        },
        // 是否需要背景
        hasBg:{
            type:Boolean,
            default:true
        }
    },
    data() {
        return {

        };
    },
    mounted() {
        var vm = this;
        // 左侧导航
        var navData = [{
                title: "首页",
                //own: "is-own",
                //iconSrc: "../../images/sideBar/fj-sider-icon_home.png",
                //activeIconSrc: "../../images/sideBar/fj-sider-icon_home1.png",
                //arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                //activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                route: "/index"/* ,
                children: [] */
            },
            {
                title: "工作管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_gzgl.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_gzgl1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "工作任务",
                        route: "/work-manage-mission",
                        children: [{
                                title: "考勤历史",
                                route: "/fjAttend-history",
                                children: [{
                                        title: "考勤历史",
                                        route: "/fjAttend-history",
                                        children: [{
                                                title: "考勤历史",
                                                route: "/fjAttend-history1",
                                                children: [{
                                                        title: "考勤历史",
                                                        route: "/fjAttend-history2",
                                                        children: [{
                                                                title: "考勤历史",
                                                                route: "/fjAttend-history3"
                                                            },
                                                            {
                                                                title: "请假休假",
                                                                route: "/fjAttend-leave2"
                                                            },
                                                            {
                                                                title: "考勤申诉",
                                                                route: "/fjAttend-appeal"
                                                            },
                                                            {
                                                                title: "考勤配置",
                                                                route: "/fjAttend-configure"
                                                            },
                                                            {
                                                                title: "排班管理",
                                                                route: "/fjAttend-work-manage"
                                                            }
                                                        ]
                                                    },
                                                    {
                                                        title: "请假休假",
                                                        route: "/fjAttend-leave"
                                                    },
                                                    {
                                                        title: "考勤申诉",
                                                        route: "/fjAttend-appeal"
                                                    },
                                                    {
                                                        title: "考勤配置",
                                                        route: "/fjAttend-configure"
                                                    },
                                                    {
                                                        title: "排班管理",
                                                        route: "/fjAttend-work-manage"
                                                    }
                                                ]
                                            },
                                            {
                                                title: "请假休假",
                                                route: "/fjAttend-leave"
                                            },
                                            {
                                                title: "考勤申诉",
                                                route: "/fjAttend-appeal"
                                            },
                                            {
                                                title: "考勤配置",
                                                route: "/fjAttend-configure"
                                            },
                                            {
                                                title: "排班管理",
                                                route: "/fjAttend-work-manage"
                                            }
                                        ]
                                    },
                                    {
                                        title: "请假休假",
                                        route: "/fjAttend-leave"
                                    },
                                    {
                                        title: "考勤申诉",
                                        route: "/fjAttend-appeal"
                                    },
                                    {
                                        title: "考勤配置",
                                        route: "/fjAttend-configure"
                                    },
                                    {
                                        title: "排班管理",
                                        route: "/fjAttend-work-manage"
                                    }
                                ]
                            },
                            {
                                title: "请假休假",
                                route: "/fjAttend-leave"
                            },
                            {
                                title: "考勤申诉",
                                route: "/fjAttend-appeal"
                            },
                            {
                                title: "考勤配置",
                                route: "/fjAttend-configure"
                            },
                            {
                                title: "排班管理",
                                route: "/fjAttend-work-manage",
                                children: [{
                                        title: "考勤历史1",
                                        route: "/fjAttend-history"
                                    },
                                    {
                                        title: "请假休假1",
                                        route: "/fjAttend-leave"
                                    },
                                    {
                                        title: "考勤申诉1",
                                        route: "/fjAttend-appeal"
                                    },
                                    {
                                        title: "考勤配置1",
                                        route: "/fjAttend-configure"
                                    },
                                    {
                                        title: "排班管理1",
                                        route: "/fjAttend-work-manage"
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        title: "信息采集",
                        route: "/fjWorkManage-info",
                        children: [{
                                title: "请假休假",
                                route: "/fjAttend-leave",
                                children: [{
                                        title: "请假休假",
                                        route: "/fjAttend-leave"
                                    },
                                    {
                                        title: "考勤申诉",
                                        route: "/fjAttend-appeal"
                                    },
                                    {
                                        title: "考勤配置",
                                        route: "/fjAttend-configure"
                                    },
                                    {
                                        title: "排班管理",
                                        route: "/fjAttend-work-manage"
                                    }
                                ]
                            },
                            {
                                title: "考勤申诉",
                                route: "/fjAttend-appeal"
                            },
                            {
                                title: "考勤配置",
                                route: "/fjAttend-configure"
                            },
                            {
                                title: "排班管理",
                                route: "/fjAttend-work-manage"
                            }
                        ]
                    },
                    {
                        title: "工作日志",
                        route: "/fjWorkManage-workLog"
                    }
                ]
            },
            {
                title: "考勤管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_kqgl.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_kqgl1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "考勤历史",
                        route: "/fjAttend-history"
                    },
                    {
                        title: "请假休假",
                        route: "/fjAttend-leave"
                    },
                    {
                        title: "考勤申诉",
                        route: "/fjAttend-appeal"
                    },
                    {
                        title: "考勤配置",
                        route: "/fjAttend-configure"
                    },
                    {
                        title: "排班管理",
                        route: "/fjAttend-work-manage"
                    }
                ]
            },
            {
                title: "考核管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_khgl.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_khgl1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "单位考核",
                        route: "/unit-assessment"
                    },
                    {
                        title: "地区考核",
                        route: "/local-assessment"
                    },
                    {
                        title: "个人考核",
                        route: "/personal-assessment"
                    },
                    {
                        title: "考核规则",
                        route: "/personal-assessment-rules"
                    }
                ]
            },
            {
                title: "数据中心",
                //own: "is-own",
                iconSrc: "../../images/sideBar/fj-sider-icon_data.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_data1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                route: "/data-center",
                children: []
            },
            {
                title: "新闻中心",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_news.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_news1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                route: "",
                children: [{
                        title: "信息报送",
                        route: "/fjNewsCenter-infoSubmit"
                    },
                    {
                        title: "文章管理",
                        route: "/fjNewsCenter-articleManage"
                    }
                ]
            },
            {
                title: "教培管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_jpgl.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_jpgl1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "业务知识库",
                        route: "/knowleage-center"
                    },
                    {
                        title: "培训中心",
                        route: "/training"
                    },
                    {
                        title: "专题考试",
                        route: "/special-exam"
                    }
                ]
            },
            // {
            //   title: '人事管理',
            //   own: '',
            //   src: '../../images/sideBar/fj-sider-icon_jpgl.png',
            //   selectSrc: '../../images/sideBar/fj-sider-icon_jpgl1.png',
            //   arrowSrc: '../../images/sideBar/fj-sider-arrow.png',
            //   arrowSelectedSrc: '../../images/sideBar/fj-sider-arrow1.png',
            //   children: [{
            //     title: '招聘管理',
            //     route: '/personnel-recruit'
            //   }
            //   ]
            // },
            {
                title: "人事管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_hr.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_hr.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "招聘管理",
                        route: "/personnel-recruitment"
                    },
                    {
                        title: "合同管理",
                        route: "/personnel-contract"
                    },
                    {
                        title: "档案管理",
                        route: "/personnel-archives"
                    },
                    {
                        title: "工资管理",
                        route: "/personnel-wage"
                    },
                    {
                        title: "规则管理",
                        route: "/personnel-rule-setting"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure-zzzzzzhhhhhh666666"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure666333222000"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structureQWERTYUIOP"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs"
                    }
                ]
            },
            {
                title: "系统管理___last",
                own: "",
                iconSrc: "../../images/sideBar/fj-sider-icon_sys.png",
                activeIconSrc: "../../images/sideBar/fj-sider-icon_sys1.png",
                arrowSrc: "../../images/sideBar/fj-sider-arrow.png",
                activeArrowSrc: "../../images/sideBar/fj-sider-arrow1.png",
                children: [{
                        title: "组织架构",
                        route: "/organizational-structure11231525"
                    },
                    {
                        title: "考核配置",
                        route: "/appraise-item"
                    },
                    {
                        title: "操作日志",
                        route: "/operation-logs66669999933333"
                    }
                ]
            }
        ];
        //
        window.zzSideBarObj = new zzSideBar({
            treeData: navData, //导航栏数据
            itemClickAfter: function(data) {
                //对应导航栏子项的点击事件
                //console.log(data);
                //
                var tempNavData = this.getMatchedItemsByIndex(data.index);
                console.log("---getMatchedItemsByIndex---", tempNavData);
                // 传出路径导航的数据
                vm.$emit("getnavbardata",tempNavData);
                //
                this.refreshLocationHref(data[this.settings.tabName]);
            },
            itemIconChange: function(item, data, isActive) {
                //icon
                var icon = item.children(this.settings.iconClass);
                var otherIcons = item
                    .siblings(this.settings.itemClass)
                    .children(this.settings.iconClass);
                for (var i = 0, len = otherIcons.length; i < len; i++) {
                    this.clearIconSrc(otherIcons.eq(i));
                }!isActive
                    ?
                    icon.attr("src", data[this.settings.activeIconSrc] || this.common.activeIconSrcLink) :
                    icon.attr("src", data[this.settings.iconSrc] || this.common.iconSrcLink);
            },
            itemArrowChange: function(item, data, isActive) {
                //arrow
                var otherItems = item.siblings(this.settings.itemClass);
                var arrow = item.children(this.settings.arrowClass);
                var otherArrows = otherItems.children(this.settings.arrowClass);
                //
                otherItems.removeClass("is-noHC");
                for (var i = 0, len = otherArrows.length; i < len; i++) {
                    this.clearArrowSrc(otherArrows.eq(i));
                    otherArrows.eq(i).css("transform", "rotate(0deg)");
                }
                if (!data.children || !data.children.length) {
                    !isActive
                        ?
                        arrow.attr("src", data[this.settings.activeArrowSrc]) :
                        arrow.attr("src", data[this.settings.arrowSrc]);
                    !isActive ? item.addClass("is-noHC") : item.removeClass("is-noHC");
                } else {
                    !isActive
                        ?
                        arrow.css("transform", "rotate(90deg)") :
                        arrow.css("transform", "rotate(0deg)");
                }
            },
            settings: {
                hasIcon: true, //是否有icon图标
                iconSrc: "iconSrc", //图标链接在导航数据中的字段名
                activeIconSrc: "activeIconSrc", //选中时的图标链接字段名
                hasArrow: true, //是否有箭头
                arrowSrc: "arrowSrc", //箭头图标链接在导航数据中的字段名
                activeArrowSrc: "activeArrowSrc" //选中时的箭头链接字段名
            }
        });
        //
        zzSideBarObj.init();
    }
});